home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # @(#)07 1.2 relsup/cmw301u1/bin/rmperms, scosupp, sco_3.0 3/16/95 16:00:38, SecureWare, Inc.
- #
- # rmperms - remove entries from a perms list
- #
- # usage: rmperms permsfile file ...
-
- if [ $# -lt 2 ]; then
- echo >&2 "Usage: $0 permslist filename ..."
- exit 1
- fi
- Perms="$1"
- shift
- if [ ! -r "$Perms" ]; then
- echo >&2 "$0: $Perms: file not found"
- exit 1
- fi
-
- for File in "$@"; do
- # make sure we need to worry about it at all
- /etc/fixperm -lg "$Perms" | grep '^'"$File"'$' >/dev/null || {
- echo >&2 "$0: $File: not found in perms list"
- continue;
- }
-
- # okay, now edit the perms list
- awk 'BEGIN {File="'"$File"'"}
- {
- if ($0 ~ /^[ ]*#/ || $1 == "uid" || $1 == "gid")
- {
- print;
- }
- else if ((Link <= Links) && ((NF == 2) || (NF == 1)))
- {
- if ($1 == File)
- {
- Links--;
- }
- else
- {
- Name[Link++] = $1
- }
- if (Link > Links)
- {
- printf ("%s\t%s\t%s\t%s\t%s\t%s\n",
- Pkg, Mode, Owner, Links, Name[1], Vol);
- for (i=2; i<Link; ++i)
- printf ("\t%s\t%s\n", Name[i],
- Vol);
- Links = 0;
- Link = 0;
- }
- }
- else if ((Links == 0) && ((NF == 6) || (NF == 5)))
- {
- Links=$4;
- if (Links > 1)
- {
- Pkg=$1;
- Mode=$2;
- Owner=$3;
- Vol=$6;
-
- Link=1;
- if ($5 != File)
- {
- Name[Link++] = $5;
- }
- else
- {
- Links--;
- }
- }
- else
- {
- Links=0;
- Link=0;
- if ($5 != File)
- print;
- }
- }
- }
- END { exit 0; }' "$Perms" >/tmp/rmperms$$
- if [ $? -ne 0 ]; then
- echo >&2 "$0: awk failed; perms list unchanged"
- rm -f /tmp/rmperms$$
- else
- mv -f /tmp/rmperms$$ "$Perms"
- fi
- done
-